﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Entities;
using Utility;
using BUS;

public partial class Administrator_doanhnghiep_chitiet : System.Web.UI.Page
{
    public int STT=0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username_dn"] != null)
            {
                load_data();
            }
            else
            {
                Response.Redirect("~/A_LetsDeal-DoanhNghiep/Default.aspx");
            }
        }
    }

    private void load_data()
    {
        string id = Session["username_dn"].ToString();
        Tbl_DoanhNghiep_Entities dn = Tbl_DoanhNghiep_BUS.GetByName(id);
        lit_madoanhnghiep.Text = dn.MaDN;
        txt_tendoanh.Text = dn.TenDN;
        txt_dc.Text = dn.DiaChi;
        txt_sdt.Text = dn.SDT;
        txt_website.Text = dn.WebSite;
        txt_gioithieu.Text = dn.GioiThieu;
        lit_taikhoan.Text = dn.TaiKhoan;
        lit_sodutaikhoan.Text = String.Format("{0:0,0 đ}",dn.SoDuTaiKhoan);
    }

    protected void bt_save_Click(object sender, EventArgs e)
    {
        Tbl_DoanhNghiep_Entities dnnew = new Tbl_DoanhNghiep_Entities();
        string id = Session["username_dn"].ToString();
        Tbl_DoanhNghiep_Entities dn = Tbl_DoanhNghiep_BUS.GetByName(id);
        dnnew.STT = dn.STT;
        dnnew.MaDN = lit_madoanhnghiep.Text;
        dnnew.TenDN = txt_tendoanh.Text;
        dnnew.DiaChi = txt_dc.Text;
        dnnew.SDT = txt_sdt.Text;
        dnnew.WebSite = txt_website.Text;
        dnnew.GioiThieu = txt_gioithieu.Text;
        dnnew.TaiKhoan = lit_taikhoan.Text;
        dnnew.MatKhau = dn.MatKhau;
        dnnew.SoDuTaiKhoan = dn.SoDuTaiKhoan;
        dnnew.LoaiTK = dn.LoaiTK;
        Tbl_DoanhNghiep_BUS.Update(dnnew);
    }
}
